<script setup>

const visible = ref(false)

const resolve = ref()

const options = ref({})

const show = _options => {
    return new Promise(_resolve => {
        options.value = _options
        resolve.value = _resolve
        visible.value = true
    })
}

const columns = computed(() => {
    if (options.value.data) {
        return [options.value.data.map(item => item.label)]
    }
    return []
})

const confirm = event => {
    const index = event.indexs[0]
    resolve.value({
        confirm: true,
        item: options.value.data[index]
    })
    visible.value = false
}

const cancel = () => {
    resolve.value({
        confirm: false
    })
    visible.value = false
}

qly.tool.setTool('qlyMessageSelect', show)


</script>

<template>
    <up-picker :title="options.title" :show="visible" :columns="columns" @confirm="confirm" @cancel="cancel"/>
</template>

<style scoped>

</style>